#include "animalwidget.h"
#include "ui_animalwidget.h"

AnimalWidget::AnimalWidget(QWidget *parent, QSharedPointer<Animal> animal):
    QWidget(parent),
    ui(new Ui::AnimalWidget)
{
    ui->setupUi(this);
    init(animal);
}
AnimalWidget::~AnimalWidget()
{
    delete ui;
}

void AnimalWidget::init(QSharedPointer<Animal> animal)
{
    if(animal==nullptr)return;
    ui->nameLine->setText(QString::fromStdString(animal->getName()));
    ui->ageLine->setText(QString::number(animal->getAge()));
    ui->voiceLine->setText(QString::fromStdString(animal->getVoice()));
    ui->classLine->setText(QString::fromStdString(animal->getClass()));
    ui->nameLine->setReadOnly(true);
    ui->ageLine->setReadOnly(true);
    ui->classLine->setReadOnly(true);
    ui->voiceLine->setReadOnly(true);
}
